<template>
  <div class="like-page">
    <van-nav-bar fixed title="我的点赞" />
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <article-item v-for="(item,i) in rows" :key="i" :item="item" />
    </van-list>
  </div>
</template>

<script>
import { getDetailCollect } from '../api/article'
import ArticleItem from '../components/article-item'
export default {
  name: 'collect-page',
  components: { ArticleItem },
  data() {
    return {
      rows: [],
      current: 1,
      loading: false,
      finished: false
    }
  },
  methods: {
    async onLoad() {
      const { data: { data: res } } = await getDetailCollect({
        optType: 2,
        pageSize: 10,
        page: this.current
      })
      this.rows.push(...res.rows)
      this.loading = false
      if (this.current === res.pageTotal) {
        this.finished = true
      }
      this.current++
    }
  }
}
</script>

<style lang="less" scoped>
.like-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
</style>
